package net.wxxr.http.request;

import java.io.File;

import net.wxxr.http.auth.PostAuthSign;
import net.wxxr.http.auth.PutAuthSign;
import net.wxxr.http.engine.HttpPostMutipleEngine;



/**
 *
 * 文件上传请求对象
 * @author yuanwenfei
 */
public class HttpPostMutipleRequest extends HttpPostRequest {

	/** post参数里的文件的key,在我们应用里为pic或者image,默认为pic */
	private String fileKey;
	/** 要上传文件的全路径 */
	private String filePathName;
	/** 要上传文件 */
	private File file;
	
	public String getFilePathName() {
		return filePathName;
	}

	public void setFilePathName(String filePathName) {
		this.filePathName = filePathName;
	}

	public File getFile() {
		if(file == null) {
			if(filePathName == null || "".equals(filePathName)) {
				return null;
			}
			file = new File(filePathName);
			if(!file.exists()) {
				return null;
			}
		}
		return file;
	}

	public void setFile(File file) {
		this.file = file;
	}

	public String getFileKey() {
		if(fileKey == null || "".equals(fileKey)) {
			fileKey = "pic";
		}
		return fileKey;
	}

	public void setFileKey(String fileKey) {
		this.fileKey = fileKey;
	} 

	@Override
	protected void initHttpEngine() {
		httpEngine = new HttpPostMutipleEngine(this);
	}
	protected void initAuthSign() {
	if(authSign == null) {
		authSign =  new PostAuthSign(consumer, this);
	}
	}
}
